/*
 * file:  expr.cpp (implementation of Expr).
 * Author: Jeremy Johnson 
 * Date: 1/29/06
 *
 * Description: 
 */

#include <iostream>
#include <string>
#include <map>

#include "expr.h"

using namespace std;




Number::Number(int value)
{
	value_ = value;
}

int Number::eval(map<string,int> T) const
{
	return value_;
}

Ident::Ident(string name)
{
	name_ = name;
}

int Ident::eval(map<string,int> T) const
{
	return T[name_];
}

Plus::Plus(Expr* op1, Expr* op2)
{
	op1_ = op1;
	op2_ = op2;
}

int Plus::eval(map<string,int> T) const
{
	return op1_->eval(T) + op2_->eval(T);
}

Minus::Minus(Expr* op1, Expr* op2)
{
	op1_ = op1;
	op2_ = op2;
}

int Minus::eval(map<string,int> T) const
{
	return op1_->eval(T) - op2_->eval(T);
}

Times::Times(Expr* op1, Expr* op2)
{
	op1_ = op1;
	op2_ = op2;
}

int Times::eval(map<string,int> T) const
{
	return op1_->eval(T) * op2_->eval(T);
}
